package com.qianbao.qianbaobusiness.ui.qrcode;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.baseandroid.mvp.BaseMvpActivity;
import com.bumptech.glide.Glide;
import com.qianbao.qianbaobusiness.R;
import com.qianbao.qianbaobusiness.json.JumpBean;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.OnClick;

public class SaveCompleteActivity extends BaseMvpActivity<SaveCompleteView, SaveCompletePresenter> {

    @BindView(R.id.iv_qr)
    ImageView      iv_qr;
    @BindView(R.id.toolbar_title)
    TextView       toolbar_title;
    @BindView(R.id.toolbar_back)
    RelativeLayout toolbar_back;
    @BindView(R.id.right_text)
    TextView       rightText;
    private String imgUrl;

    public static void start(Context context, String imgUrl) {
        Intent intent = new Intent(context, SaveCompleteActivity.class);
        intent.putExtra("imgUrl", imgUrl);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_save_complete;
    }

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    protected void setupView() {
        imgUrl = getIntent().getStringExtra("imgUrl");
        toolbar_title.setText("保存图片");
        Glide.with(this).load(imgUrl).into(iv_qr);
        rightText.setVisibility(View.VISIBLE);
        rightText.setText(getApplicationContext().getResources().getString(R.string.complete));
        rightText.setTextColor(getApplicationContext().getResources().getColor(R.color.text_important));
    }

    @Override
    protected void setupData(Bundle savedInstanceState) {

    }

    @OnClick({R.id.toolbar_back, R.id.right_text})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.toolbar_back:
                finish();
                break;

            case R.id.right_text:      //完成
                EventBus.getDefault().post(new JumpBean("complete"));
                finish();
                break;
            default:
                break;
        }
    }
}
